import shlex

curl_command = """curl 'https://seller.shopee.tw/api/mass/mpsku/upload_edit_template/?timestamp=1738835928879&SPC_CDS=1e4c1362-ce17-4fa0-9cc0-74fa5c1997cd&SPC_CDS_VER=2' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'x-sap-ri: d887a467b706be443f336733050107bf743e913876f53739a3fe' \
  -H 'af-ac-enc-sz-token: ScRyPJUpkU5D9E8bwSUqtA==|nOy/Li0vwH+1O1XQKqKwReFo+ceCesiTkRMZtydfSo4qUQ38b66I3XsHXO/XSEaEvTfMc58laiXbEyddTW4=|P5bdWiR6rPbhnXE5|08|3' \
  -H 'Referer: https://seller.shopee.tw/portal/product-mass/mass-update/upload' \
  -H 'sec-ch-ua: "Not A(Brand";v="8", "Chromium";v="132", "Google Chrome";v="132"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sz-dfp: i7KE+46irhQld7RyETuAQA==|Od2/Li0vwH+1O1XQKqKwReFo+ceCesiTkRMZt6wMPe8tUQ38b66I3XsHXO/XSEaEvTfMc58laiXbESddTWc=|P5bdWiR6rPbhnXE5|08|3' \
  -H 'sc-fe-session: 17FAB26AEC86113A' \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'sc-fe-ver: 21.84148' \
  -H 'locale: zh-Hant' \
  -H 'x-sap-sec: t3RaCW+vnj+RDlTbFjdbFlSbhjRsFfabArdjFzTbzXQnFi4bkjdNFfYbajdpFlkb5NdRFwobONQbFg4bgjREFG1bDjRwFmab4rROFG7b8rdrFw4brjQ2Fg7bwjRpFYdbxjQ7Fwib9rdAFmdb5jRlFwTbHjd6FyqbYNRmFlSbjjdeFz7bfjRhFjdbdj7bFjdbFjMLNLA3FjdbmKIf80LVFNdbFjdbOGPNjjorFNdb1j0bFznNxe1bFgXgmj7bFjdbHS9bFwdOFjRlefy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bFg+bFjRu9IiU/yvLPN3O30HnES7qNAZUOU9qzzFTMt0clbhBNF1bFjdzFjdbxsuc715H2YqzFjdbZW4EuF0htJSbFjdb' \
  -H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundary9gbFscquKz620Y6o' \
  --data-raw $'------WebKitFormBoundary9gbFscquKz620Y6o\r\nContent-Disposition: form-data; name="file"; filename="5.xlsx"\r\nContent-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\r\n\r\n\r\n------WebKitFormBoundary9gbFscquKz620Y6o--\r\n'"""

# 解析 curl 命令，提取 URL、头部和数据
curl_command = shlex.split(curl_command)  # 使用 shlex 解析 curl 命令
url = None
data = None
method = 'POST'  # 默认方法是 POST
headers = {}

# 通过查找 -X 或 --data-raw 来提取 URL 和方法
for i in range(len(curl_command)):
    if curl_command[i] == "curl":
        continue
    elif curl_command[i] == "-X":
        method = curl_command[i + 1]
    elif curl_command[i] == "--data-raw":
        data = curl_command[i + 1]

    # 提取 URL
    if curl_command[i].startswith("http"):
        url = curl_command[i]

    # 提取 Header
    if curl_command[i] == "-H":
        header = curl_command[i + 1]
        if ":" in header:
            key, value = header.split(":", 1)
            headers[key.strip()] = value.strip()

print(f"URL: {url}")
print(f"Method: {method}")
print(f"Data: {data}")
print(f"Headers: {headers}")